package com.lam.mall.service.impl;

import java.util.List;
import java.util.Objects;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lam.common.utils.StringUtils;
import com.lam.mall.entity.OrderLog;
import com.lam.mall.mapper.OrderLogMapper;
import com.lam.mall.param.OrderLogParam;
import com.lam.mall.service.OrderLogService;

/**
 * 订单日志Service业务层处理
 * 
 * @author admin
 * @date 2023-04-26
 */
@Service
public class OrderLogServiceImpl  implements OrderLogService {

    @Autowired
    private OrderLogMapper orderLogMapper;

    /**
     * 查询订单日志
     * 
     * @param id ID
     * @return 单个对象
     */
    @Override
    @Transactional(readOnly = true)
    public OrderLog selectById(String id) {

        return orderLogMapper.selectById(id);
    }

    /**
     * 查询订单日志列表
     * 
     * @param param
     * @return 
     */
    @Override
    @Transactional(readOnly = true)
    public List<OrderLog> selectList(OrderLogParam param) {
    
        QueryWrapper<OrderLog> queryWrapper = new QueryWrapper<>();
        
        queryWrapper.eq(Objects.nonNull(param.getShopId()), "shop_id", param.getShopId());
        queryWrapper.eq(StringUtils.isNotBlank(param.getOrderNumber()), "order_number", param.getOrderNumber());

        return orderLogMapper.selectList(queryWrapper);
    }

    /**
     * 新增订单日志
     * 
     * @param orderLog 
     * @return 
     */
    @Override
    @Transactional
    public int insert(OrderLog orderLog) {
    
        return orderLogMapper.insert(orderLog);
    }

    /**
     * 修改订单日志
     * 
     * @param orderLog 
     * @return 
     */
    @Override
    @Transactional
    public int update(OrderLog orderLog) {
    
        return orderLogMapper.updateById(orderLog);
    }

}
